// pages/common/feedback/error-type/index.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        show: {
            type: Boolean,
            value: true
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        _isShowType: false,
        _typeList: [
            "功能异常",
            "产品建议"
        ],
        _errTypeList: [
            "无法打开小程序",
            "小程序闪退",
            "卡顿",
            "黑屏白屏",
            "死机",
            "界面错位",
            "加载慢",
            "其它异常"
        ]
    },

    attached: function () {
        this.setData({_isShowType: true})
    },

    /**
     * 组件的方法列表
     */
    methods: {
        /*
        * 类型选择
        * */
        bindTypeSelect: function (e) {
            let typeList = this.data._typeList;
            let index = e.currentTarget.dataset.index;
            if (index === 0) {
                this.setData({_isShowType: false})
            } else {
                this.triggerEvent("typeSelect", {
                    typeName: typeList[index]
                }, {});
            }
        },

        /*
        * 错误类型选择
        * */
        bindErrorSelect: function (e) {
            let index = e.currentTarget.dataset.index;
            let typeList = this.data._typeList;
            let errTypeList = this.data._errTypeList;
            this.triggerEvent("typeSelect", {
                typeName: typeList[0],
                errorName: errTypeList[index]
            }, {});
        }
    }
})
